package console

import (
	"fmt"

	"com.game.snake/consts"
	"com.game.snake/msg"
)

func (handle *handler) rander(msg msg.GameData) {
	fmt.Println()
	fmt.Println(" ∴∴∴∴∴ 贪吃蛇 ∴∴∴∴∴ ")
	fmt.Println()
	for _, cols := range msg.World {
		for _, cell := range cols {
			if cell == nil {
				fmt.Print(" ", consts.CELL_EMPTY)
			} else if cell.IsFood() {
				fmt.Print(" ", consts.CELL_FOOD) // 就不打印子类型了
			} else if cell.IsObstacle() {
				fmt.Print(" ", consts.CELL_OBSTACLE) // 就不打印子类型了
			} else if cell.IsSnake() {
				fmt.Print(" ", consts.CELL_SNAKE)
			} else {
				fmt.Print(" ", "!")
			}
		}
		fmt.Println("")
	}
	fmt.Printf("\r\n控制：%s=上/%s=下/%s=左/%s=右/%s=退/%s=重新开始 （需要回车）\r\n",
		consts.DirectionUp, consts.DirectionDown, consts.DirectionLeft, consts.DirectionRight,
		consts.CMD_QUIT, consts.CMD_RESTART)
}
